package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author hzy
 * @since 2023-09-12
 */
@RestController
@RequestMapping("/likes")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "点赞系统")
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;

    /**
     * 点赞或取消
     *
     * @param dto
     */
    @ApiOperation("点赞或取消")
    @PostMapping
    public void isLikes(@Validated @RequestBody LikeRecordFormDTO dto) {
        likedRecordService.isLikes(dto);
    }

    /**
     * 查询点赞状态
     *
     * @param bizIds
     * @return
     */
    @ApiOperation("查询点赞状态")
    @GetMapping("/")
    public Set<Long> selectLikesStatus(@RequestParam("bizType") String bizType, @RequestParam("bizIds") List<Long> bizIds) {
        return likedRecordService.selectLikesStatus(bizType, bizIds);
    }
}
